home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Compute`s Amiga resource 1.adf / Source / 8ColorWbench / Colorbench.a next >
Text File  |  1989-02-08  |  3KB  |  129 lines

  1. ;*************************************************************************
  2. ;
  3. ;    Colorbench.a
  4. ;
  5. ;    Double the number of colors available on the Workbench screen by
  6. ; adding another bitplane.
  7. ;
  8. ;*************************************************************************
  9.  
  10. ; Constants
  11.  
  12. _AbsExecBase    EQU    4    ;base addr for Exec
  13.  
  14. _CloseLibrary    EQU    -414
  15. _RemakeDisplay    EQU    -384
  16. _BltClear    EQU    -300
  17. _AllocRaster    EQU    -492
  18. _OpenWorkBench    EQU    -210
  19. _OpenLibrary    EQU    -552
  20.  
  21. LIB_VERSION    EQU    32    ;KS 1.2 or higher
  22. BITMAP        EQU    88    ;offset to BitMap structure
  23. DEPTH        EQU    5    ;offset to number of bitplanes
  24. WIDTH        EQU    12    ;offset to bitplane width
  25. HEIGHT        EQU    14    ;offset to bitplane height
  26. PLANES        EQU    16    ;offset to 3rd bitplane ptr
  27.  
  28.  
  29.  
  30.  
  31.     SECTION    Program,CODE
  32.  
  33. Start:
  34.     movea.l    _AbsExecBase,a6        ;get ptr to Exec library
  35.  
  36. ; open intuition library
  37.     lea    IntuitionName,a1    ;ptr to "intuition.library"
  38.     moveq.l    #LIB_VERSION,d0        ;set library version
  39.     jsr    _OpenLibrary(a6)    ;call OpenLibrary
  40.     move.l    d0,IntuitionBase    ;store the addr
  41.     beq    Exit            ;problem -- drop out
  42.  
  43. ; open graphics library
  44.     lea    GfxName,a1        ;ptr to "graphics.library"
  45.     moveq.l    #LIB_VERSION,d0        ;set library version
  46.     jsr    _OpenLibrary(a6)    ;call OpenLibrary
  47.     move.l    d0,GfxBase        ;store the addr
  48.     beq    CloseIntuition        ;problem -- drop out
  49.  
  50. ; get a ptr to the workbench screen structure using OpenWorkBench
  51.     movea.l IntuitionBase,a6    ;base addr of intuition library
  52.     jsr    _OpenWorkBench(a6)    ;call OpenWorkBench
  53.     move.l    d0,Scr            ;store the addr
  54.     beq    AllDone            ;problem -- drop out
  55.  
  56. ; get a ptr to the BitMap structure within the screen's RastPort structure
  57.     movea.l    Scr,a0
  58.     move.l    BITMAP(a0),bm
  59.  
  60. ; decide whether to add a bitplane
  61.     movea.l    bm,a0
  62.     move.b    DEPTH(a0),d0
  63.     cmpi.b    #2,d0            ;2 bitplanes?
  64.     bne    AllDone            ;no
  65.  
  66. ; yes, so add one bitplane
  67.     movea.l    Scr,a0            ;addr of screen structure
  68.     move.w    HEIGHT(a0),d1        ;height of bitmap
  69.     move.w    WIDTH(a0),d0        ;width of bitmap
  70.     movea.l    GfxBase,a6        ;base addr of graphics library
  71.     jsr    _AllocRaster(a6)    ;call AllocRaster
  72.     movea.l    bm,a0            ;AllocRaster returns ptr in d0
  73.     move.l    d0,PLANES(a0)        ;bm->Plane[2] = d0
  74.  
  75. ; clear the bitplane we just allocated
  76.     movea.l    Scr,a0            ;
  77.     clr.l    d0            ;put the number of bytes to
  78.     move.w    WIDTH(a0),d0        ; clear in d0
  79.     divs    #8,d0            ; bytes =
  80.     muls    HEIGHT(a0),d0        ;      WIDTH / 8 * HEIGHT
  81.     movea.l    bm,a0
  82.     movea.l    PLANES(a0),a1        ;put the addr of the bitplane in a1
  83.     clr.l    d1            ;set flag to wait on BltClear
  84.     jsr    _BltClear(a6)        ;call BltClear
  85.  
  86. ; set the number of bitplanes to 3
  87.     movea.l    bm,a0
  88.     move.b    #3,DEPTH(a0)        ;bm->DEPTH = 3
  89.  
  90. ; rebuild the display
  91.     movea.l    IntuitionBase,a6
  92.     jsr    _RemakeDisplay(a6)    ;call RemakeDisplay
  93.                     ;fall through to AllDone
  94.  
  95. ; finish by closing the libraries
  96. AllDone:
  97.     movea.l    GfxBase,a1        ;close graphics.library
  98.     movea.l    _AbsExecBase,a6
  99.     jsr    _CloseLibrary(a6)    ;call CloseLibrary
  100.  
  101. CloseIntuition:
  102.     movea.l    IntuitionBase,a1    ;close intuition.library
  103.     jsr    _CloseLibrary(a6)    ;call CloseLibrary
  104.  
  105. Exit:
  106.     rts                ;back to CLI
  107.  
  108.  
  109.  
  110.  
  111.     SECTION    InitData,DATA
  112.  
  113. IntuitionName:
  114.     dc.b    'intuition.library',0
  115. GfxName:
  116.     dc.b    'graphics.library',0
  117.  
  118.  
  119.  
  120.  
  121.     SECTION    UnInitData,BSS
  122.  
  123. Scr        ds.l 1
  124. bm        ds.l 1
  125. IntuitionBase    ds.l 1
  126. GfxBase        ds.l 1
  127.  
  128.     end
  129.